package com.qf.person.advanced.impl;

import com.qf.person.advanced.RowMapper;
import com.qf.person.entity.Person;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;

/**
 * @author wangyu
 * @Classname: PersonRowMapper
 * @Description: TEST
 * @date 2022-04-08 13:18
 */
public class PersonRowMapper implements RowMapper<Person> {

    @Override
    public Person getRow(ResultSet resultSet) {
        Person person = null;
        try {
            int pid = resultSet.getInt("id");
            String name = resultSet.getString("name");
            int age = resultSet.getInt("age");
            Date bornDate = resultSet.getDate("bornDate");
            String email = resultSet.getString("email");
            String adress = resultSet.getString("adress");
            person = new Person(pid,name,age,bornDate,email,adress);
            return  person;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}
